package com.beaven.model.data.user;

import com.beaven.model.data.BaseDbRepository;
import com.beaven.model.data.DbDataSource;
import com.beaven.model.model.db.Category;
import com.beaven.model.model.db.Category_Table;
import com.beaven.model.model.sp.Account;
import com.raizlabs.android.dbflow.sql.language.SQLite;
import java.util.List;

/**
 * author: Beaven
 * time: 2017/5/27 16:58
 */

public class CategoryRepository extends BaseDbRepository<Category> implements
    DbDataSource<Category> {

  @Override public void load(SuccessCallBack<List<Category>> callBack) {
    super.load(callBack);
    SQLite.select()
        .from(Category.class)
        .where(Category_Table.ownerId.eq(Account.getUserId()))
        .orderBy(Category_Table.name, true)
        .async()
        .queryListResultCallback(this)
        .execute();
  }
}
